package com.guoxue.util;


import javax.annotation.Resource;

import org.springframework.stereotype.Component;

import redis.clients.jedis.Jedis;
@Component
public class CheckForStaticResources extends Thread{
	
	@Resource
	private LoadConfigProperties loadConfigProperties;
	private static String versionCode = "";

	@Override
	public void run() {
		while(true){
			Jedis jedis = RedisUtil.getJedis();
			try {
				if (jedis.get("checkVsersionCode")!=null&&jedis.get("checkVsersionCode")!=""&&!jedis.get("checkVsersionCode").equals(versionCode)){ //判断版本号是否与本机相同
					versionCode =  jedis.get("checkVsersionCode");
					loadConfigProperties.loadValue();
					System.err.println("发布加载了："+OtherUtils.getCurrentDate());
				}else{
					loadConfigProperties.valueInit();
					System.err.println("实时加载了："+OtherUtils.getCurrentDate());
				}
			} catch (Exception e) {
				LoggerUtil.error(e);
			}finally {
				jedis.close();
			}
			try {
				CheckForStaticResources.sleep(1000*60*30);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}
	}
}
